const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
const Version = 'v=' + new Date().getTime()

module.exports = {
  outputDir: 'formFront',
  transpileDependencies: true,
  publicPath: process.env.BASE_URL,
  configureWebpack: {
    plugins: [
      AutoImport({
        resolvers: [ElementPlusResolver()]
      }),
      Components({
        resolvers: [ElementPlusResolver()]
      })
    ],
    externals: {
      AWSC: 'AWSC'
    },
    output: {
      filename: `js/[name].${Version}.js`,         // js打包文件，添加时间戳
      chunkFilename: `js/[name].${Version}.js`
    }
  },
  css: {
    extract: {
      filename: `css/[name].${Version}.css`,
      chunkFilename: `css/[name].${Version}.css`
    }
  },
  devServer: {
    port: 8080,
    client: {
      overlay: false
    },
    proxy: {
      '/admin_api': {
        target: process.env.VUE_APP_BASE_API,
        changeOrigin: true,
        ws: true,
        pathRewrite: {
          '^/admin_api': ''
        },
        onProxyReq(proxyReq) {
          proxyReq.removeHeader('origin')
        }
      },
      '/recruitment_api': {
        target: 'http://10.10.0.78:9114',
        changeOrigin: true,
        ws: true,
        pathRewrite: {
          '^/recruitment_api': ''
        },
        onProxyReq(proxyReq){
          proxyReq.removeHeader('origin') 
        }
      },
      '/form_api': {
        // target: 'http://10.10.0.120:9100',
        target: 'http://10.10.0.78:9113',
        changeOrigin: true,
        ws: true,
        pathRewrite: {
          '^/form_api': ''
        },
        onProxyReq(proxyReq) {
          proxyReq.removeHeader('origin')
        }
      }
    }
  }
}
